#include <string>
#include <netinet/in.h>
#include <vector>

#define SEVPORT 4829
#define LOCALHOST "127.0.0.1"
#define ESTABLISH 1
#define UNESTABLISH 0
#define BUFFER_SIZE 1024

class Client
{
public:
  Client(std::string name);
  ~Client(){};
  bool help();
  friend void cmd_handler(Client& clt);
  friend void rcv_handler(Client& clt);

private:
  std::string server_name = "unknown";
  std::string client_name = "client";
  int sockfd = -1;

  in_port_t remote_port = SEVPORT;
  bool link_status = UNESTABLISH;

  bool link(const char* localhost, in_port_t port);  /* connect */
  bool unlink();  /* disconnect */
  bool request_name();  /* get the name of the server */
  bool request_time();  /* get the time when the server receives the message */
  bool request_info();  /* all clients' name of the server */
  bool request_forward(std::string name, std::string msg); /* forward message for another client*/
  bool send_msg(std::string msg); /* provide service for request function */
  bool quit(); /* terminate the program */

  std::vector<std::string> cmd_lexer(std::string cmd);
  bool cmd_action(std::vector<std::string> token);
};

void cmd_handler(Client&);

void rcv_handler(Client&);
